<template>
    <view :style="{'--color': color}">
        <status-bar title='赠送记录'></status-bar>
        <view class="p-left40 p-right40" v-if="list.length">
            <view class="d-flex a-center p-top30 p-bot30 bot_bor_ee" v-for="(item,index) in list" :key="index">
                <view class="flex-1">
                    <view class="size30 color_33 bold m-bot10">{{ item.userFind.v_name }}（{{ item.userFind.v_tel }}）</view>
                    <view class="size26 color_99">{{ item.addDate }}</view>
                </view>
                <view :class="item.con_status == 1 ? 'success-color' : 'error-color'">
                    <text class="size40">{{ item.con_status == 1 ? '+' : '-' }}</text>
                    <text class="size40">{{ item.con_value }}</text>
                </view>
            </view>
        </view>
        <empty v-if="noData" cat='3' msg='您还没有相关记录哦'></empty>
    </view>
</template>

<script>
import { mapState } from 'vuex'
export default {
    data(){
        return {
            list: [],
            noData: false,
            page: 1,
            pageNum: 10,
            noMore: false,
            type: '2' // 1查积分、2查余额、3查收益
        }
    },
    computed: {
        ...mapState(['color'])
    },
    onLoad(e){
        if(e.type) this.type = e.type
        this.getList()
    },
    methods: {
        getList(){
            this.$http.post({
                url: '/osmxcxApi/getGiveLog',
                data: {
                    page: this.page,
                    pageNum: this.pageNum,
                    type: this.type
                }
            }).then(res=>{
                let result = res.data || []
                this.list = this.page == 1 ? result : this.list.concat(result)
                if(result.length < this.pageNum) this.noMore = true
                if(!this.list.length) this.noData = true
            })
        }
    },
    onReachBottom(){
        if(this.noMore) return
        this.page ++ 
        this.getList()
    }
}
</script>

<style lang="scss" scoped>

</style>